package baseFx.serialization.json.jackson;

import baseFx.common.utils.EnumUtils;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.DeserializationConfig;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.module.SimpleDeserializers;

public class HookDeserializers extends SimpleDeserializers {
    @Override
    public JsonDeserializer<?> findEnumDeserializer(Class<?> type, DeserializationConfig config, BeanDescription beanDesc) throws JsonMappingException {
        if (type.isEnum() && EnumUtils.isIdEnum(type)) {
            return new EnumDeserializer((Class<Enum<?>>) type);
        }
        return super.findEnumDeserializer(type, config, beanDesc);
    }
}
